<?php

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
use App\Models\Scope\CompanyScope;



$factory->define(App\Models\RealControlDevice::class, function (Faker\Generator $faker) {
    return [
        'rd_updatetime' => date('Y-m-d H:i:s'),
        'pdi_index' => 0,
        'rd_NetCom' => 1,
    ];
});

$factory->define(App\Models\PriDeviceInfo::class, function (Faker\Generator $faker) {
    $areas = App\Models\Site::get()->toArray();
    $oneArea = $faker->randomElement($areas);
    
    $types = App\Models\DeviceType::get()->toArray();
    $oneType = $faker->randomElement($types);
    return [
        'pdi_name' => $faker->word(),
        'pdi_code' => mt_rand(10000000, 99999999),
        'dpt_id' =>  array_get($oneType, 'dt_typeid'),
        'Co_ID' =>  array_get($oneArea, 'company_id'),
        'AreaId' => array_get($oneArea, 'id'),
        'pdi_updatetime' => date('Y-m-d H:i:s'),
    ];
});


